//
// Created by Lenovo on 2020/9/28.
//

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
#define ll long long
const int maxn = 1e4+10;
int main()
{
    int t;
    cin>>t;
    int kcase = 0;
    while(t--)
    {
        ll n;
        cin>>n;
        ll ans = 0;
        for(int i = 1;i<=n+1;i++)
        {
            ll x;
            cin>>x;
            ans += x;
        }
        ll maxx = 0;
        ll a,b;
        for(int i = 1;i<=n;i++)
        {
            cin>>a>>b;
            maxx = max(maxx,b);
        }
        printf("Case #%d: %lld.000000\n",++kcase,maxx+ans);
    }

}